home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 1.iso / toolbox / src / demos / OpenGL / tex_cube / myimage.h < prev    next >
C/C++ Source or Header  |  1996-11-11  |  4KB  |  117 lines

  1. /*
  2.  * (c) Copyright 1993, 1994, Silicon Graphics, Inc.
  3.  * ALL RIGHTS RESERVED
  4.  * Permission to use, copy, modify, and distribute this software for
  5.  * any purpose and without fee is hereby granted, provided that the above
  6.  * copyright notice appear in all copies and that both the copyright notice
  7.  * and this permission notice appear in supporting documentation, and that
  8.  * the name of Silicon Graphics, Inc. not be used in advertising
  9.  * or publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.
  11.  *
  12.  * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
  13.  * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
  14.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
  15.  * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
  16.  * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
  17.  * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
  18.  * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
  19.  * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
  20.  * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
  21.  * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
  22.  * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
  23.  * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
  24.  *
  25.  * US Government Users Restricted Rights
  26.  * Use, duplication, or disclosure by the Government is subject to
  27.  * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
  28.  * (c)(1)(ii) of the Rights in Technical Data and Computer Software
  29.  * clause at DFARS 252.227-7013 and/or in similar or successor
  30.  * clauses in the FAR or the DOD or NASA FAR Supplement.
  31.  * Unpublished-- rights reserved under the copyright laws of the
  32.  * United States.  Contractor/manufacturer is Silicon Graphics,
  33.  * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
  34.  *
  35.  * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
  36.  */
  37. #ifndef    __GL_IMAGE_H__
  38. #define    __GL_IMAGE_H__
  39. /*
  40.  *    Defines for image files . . . .
  41.  *
  42.  *              Paul Haeberli - 1984
  43.  *      Look in /usr/people/4Dgifts/iristools/imgtools for example code!
  44.  *
  45.  */
  46.  
  47. #include <stdio.h>
  48.  
  49. #define IMAGIC     0732
  50.  
  51. /* colormap of images */
  52. #define CM_NORMAL        0    /* file contains rows of values which 
  53.                      * are either RGB values (zsize == 3) 
  54.                      * or greyramp values (zsize == 1) */
  55. #define CM_DITHERED        1
  56. #define CM_SCREEN        2    /* file contains data which is a screen
  57.                      * image; getrow returns buffer which 
  58.                      * can be displayed directly with 
  59.                      * writepixels */
  60. #define CM_COLORMAP        3    /* a colormap file */
  61.  
  62. #define TYPEMASK        0xff00
  63. #define BPPMASK            0x00ff
  64. #define ITYPE_VERBATIM        0x0000
  65. #define ITYPE_RLE        0x0100
  66. #define ISRLE(type)        (((type) & 0xff00) == ITYPE_RLE)
  67. #define ISVERBATIM(type)    (((type) & 0xff00) == ITYPE_VERBATIM)
  68. #define BPP(type)        ((type) & BPPMASK)
  69. #define RLE(bpp)        (ITYPE_RLE | (bpp))
  70. #define VERBATIM(bpp)        (ITYPE_VERBATIM | (bpp))
  71. #define    IBUFSIZE(pixels)    ((pixels+(pixels>>6))<<2)
  72. #define    RLE_NOP            0x00
  73.  
  74. #define    ierror(p)        (((p)->flags&_IOERR)!=0)
  75. #define    ifileno(p)        ((p)->file)
  76. #define    getpix(p)        (--(p)->cnt>=0 ? *(p)->ptr++ : ifilbuf(p))
  77. #define putpix(p,x)        (--(p)->cnt>=0 \
  78.                     ? ((int)(*(p)->ptr++=(unsigned)(x))) \
  79.                     : iflsbuf(p,(unsigned)(x)))
  80.  
  81. typedef struct {
  82.     unsigned short    imagic;        /* stuff saved on disk . . */
  83.     unsigned short     type;
  84.     unsigned short     dim;
  85.     unsigned short     xsize;
  86.     unsigned short     ysize;
  87.     unsigned short     zsize;
  88.     unsigned long     min;
  89.     unsigned long     max;
  90.     unsigned long    wastebytes;    
  91.     char         name[80];
  92.     unsigned long    colormap;
  93.  
  94.     long         file;        /* stuff used in core only */
  95.     unsigned short     flags;
  96.     short        dorev;
  97.     short        x;
  98.     short        y;
  99.     short        z;
  100.     short        cnt;
  101.     unsigned short    *ptr;
  102.     unsigned short    *base;
  103.     unsigned short    *tmpbuf;
  104.     unsigned long    offset;
  105.     unsigned long    rleend;        /* for rle images */
  106.     unsigned long    *rowstart;    /* for rle images */
  107.     long        *rowsize;    /* for rle images */
  108. } IMAGE;
  109.  
  110. void getrow(IMAGE *, unsigned short *, int, int);
  111. IMAGE *iopen(char *, char *);
  112. IMAGE *icreate();
  113. unsigned short *ibufalloc();
  114.  
  115. #define IMAGEDEF        /* for backwards compatibility */
  116. #endif    /* !__GL_IMAGE_H__ */
  117.